//
//  SingleTableViewCell.m
//  半糖
//
//  Created by RenShuang on 15/9/17.
//  Copyright (c) 2015年 shuang. All rights reserved.
//

#import "SingleTableViewCell.h"
#import "BaseHeader.h"

@implementation SingleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.whiteView = [[UIView alloc] initWithFrame:CGRectMake(15, 15, SCREEN_WIDTH-30, SCREEN_HEIGHT*8/24-15)];
        self.whiteView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.whiteView];
        [_whiteView release];
        
        self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, SCREEN_WIDTH-46, (SCREEN_HEIGHT*8/24-10)*22/30)];
        [self.whiteView addSubview:self.picImageView];
        [self.picImageView release];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (SCREEN_HEIGHT*8/24-10)*22/30+5, SCREEN_WIDTH-30, (SCREEN_HEIGHT*8/24-10)*8/30)];
        [self.whiteView addSubview:self.titleLabel];
        [self.titleLabel setTextAlignment:NSTextAlignmentCenter];
        [_titleLabel release];
        
        }
    return self;
}

- (void)getCell:(SingleModel *)model searchStr:(NSString *)string
{
    NSMutableAttributedString *arrtiString = [[NSMutableAttributedString alloc] initWithString:model.title];
    NSRange range = [model.title rangeOfString:string];
    [arrtiString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range];
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.pic]placeholderImage:[UIImage imageNamed:@"占位图.png"]];
    self.titleLabel.attributedText = arrtiString;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
